//
// Created by Castle on 2025/10/30.
//

#include <iostream>
using namespace std;

int main() {
    // 求两个正整数的最大公约数
    int a,b,r;
    cin >> a >> b ;
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    cout << b << endl;
    return 0;
}